#ifndef __BOOST_H__
#define __BOOST_H__

// Includes
#include <PA9.h>       // Include for PA_Lib

#include "Init.h"


//HP STONE
//---------------------------------------------
//---------------------------------------------
void useHPStone()
{
	PA_StopSpriteAnim(0, avSprNo); //stop any previous sprite animation
	
	//only execute if fully recharged
	if(hpRecharge == false)
	{
		//fill stamina guage
		player.increaseHP(player.getMaxHP());
		
		//set animation and use for loop to wait until animation
		//is complete before moving on
		PA_StartSpriteAnimEx(0, 1, 1, 7, 10, 1, 1);
		for(counter = 0; counter < 30; counter++)
		{
		PA_WaitForVBL();
		}
		
		//start recharge animation
		PA_StartSpriteAnim(0, 1, 6, 7, 5);
		//make sure everything is reset before starting
		hpBoostSeconds = 0;
		ResetTimer(hpBoostClock);
		//set recharge to true
		hpRecharge = true;
	}
	AS_SoundQuickPlay(ping);//sound effect

}

//for recharging hp stone
void chargeHPStone()
{
	//if a second has passed (1000 milliseconds)
	if(((hpBoostSeconds + 1)*1000) <= Tick(hpBoostClock))
	{	
		hpBoostSeconds++;
		//if the required number of seconds have passed
		if((hpBoostSeconds % hpBoostRestore) == 0)
		{
			//stamina stone is fully charged
			PA_StartSpriteAnim(0, 1, 0, 0, 10);
			//reset flag
			hpRecharge = false;
		}
	}	
}


//STAMINA STONE
//---------------------------------------------
//---------------------------------------------
void useStaminaStone()
{
	PA_StopSpriteAnim(0, avSprNo); //stop any previous sprite animation
	
	//only execute if fully recharged
	if(stamRecharge == false)
	{
		//fill stamina guage
		player.increaseStamina(player.getMaxStamina());
		
		//set animation and use for loop to wait until animation
		//is complete before moving on
		PA_StartSpriteAnimEx(0, 2, 9, 15, 10, 1, 1);
		for(counter = 0; counter < 30; counter++)
		{
		PA_WaitForVBL();
		}
		
		//start recharge animation
		PA_StartSpriteAnim(0, 2, 14, 15, 5);
		//make sure everything is reset before starting
		stamBoostSeconds = 0;
		ResetTimer(stamBoostClock);
		//set recharge to true
		stamRecharge = true;
		AS_SoundQuickPlay(chainsaw);//sound effect
	}

}

//for recharging stamina stone
void chargeStaminaStone()
{
	//if a second has passed (1000 milliseconds)
	if(((stamBoostSeconds + 1)*1000) <= Tick(stamBoostClock))
	{	
		stamBoostSeconds++;
		//if the required number of seconds have passed
		if((stamBoostSeconds % stamBoostRestore) == 0)
		{
			//stamina stone is fully charged
			PA_StartSpriteAnim(0, 2, 8, 8, 10);
			//reset flag
			stamRecharge = false;
		}
	}	
	
}



//ATTACK STONE
//---------------------------------------------
//---------------------------------------------
void useAttackStone()
{
	PA_StopSpriteAnim(0, avSprNo); //stop any previous sprite animation
	
	//only execute if fully recharged
	if(attRecharge == false)
	{
		//give attack boost
		player.incAttackBoost(attBoost);
		
		//set animation and use for loop to wait until animation
		//is complete before moving on
		PA_StartSpriteAnimEx(0, 3, 17, 23, 10, 1, 1);
		for(counter = 0; counter < 30; counter++)
		{
		PA_WaitForVBL();
		}
		
		//start recharge animation
		PA_StartSpriteAnim(0, 3, 22, 23, 5);
		//make sure everything is reset before starting
		attBoostSeconds = 0;
		ResetTimer(attBoostClock);
		//set recharge to true
		attRecharge = true;
	}
	
}

//for recharging attack stone
void chargeAttackStone()
{
	//if a second has passed (1000 milliseconds)
	if(((attBoostSeconds + 1)*1000) <= Tick(attBoostClock))
	{	
		attBoostSeconds++;
		//after time for full attack boost has expired, decrement
		//attack boost at every appropriate time interval
		if((attBoostSeconds > attBoostFullLength) && 
			((attBoostSeconds % attBoostDecLength) == 0))
		{
			player.decAttackBoost(decAttBoost);
		}
		//if the required number of seconds have passed
		if((attBoostSeconds % attBoostRestore) == 0)
		{
			//stamina stone is fully charged
			PA_StartSpriteAnim(0, 3, 16, 16, 10);
			//reset flag
			attRecharge = false;
		}
	}	
}




//DEFENSE STONE
//---------------------------------------------
//---------------------------------------------
void useDefenseStone()
{
	PA_StopSpriteAnim(0, avSprNo); //stop any previous sprite animation
	
	//only execute if fully recharged
	if(defRecharge == false)
	{
		//give defense boost
		player.incDefenseBoost(defBoost);
		
		//set animation and use for loop to wait until animation
		//is complete before moving on
		PA_StartSpriteAnimEx(0, 4, 25, 31, 10, 1, 1);
		for(counter = 0; counter < 30; counter++)
		{
		PA_WaitForVBL();
		}
		
		//start recharge animation
		PA_StartSpriteAnim(0, 4, 30, 31, 5);
		//make sure everything is reset before starting
		defBoostSeconds = 0;
		ResetTimer(defBoostClock);
		//set recharge to true
		defRecharge = true;
	}
	
}

//for recharging defense stone
void chargeDefenseStone()
{
	//if a second has passed (1000 milliseconds)
	if(((defBoostSeconds + 1)*1000) <= Tick(defBoostClock))
	{	
		defBoostSeconds++;
		//after time for full defense boost has expired, decrement
		//defense boost at every appropriate time interval
		if((defBoostSeconds > defBoostFullLength) && 
			((defBoostSeconds % defBoostDecLength) == 0))
		{
			player.decDefenseBoost(decDefBoost);
		}
		//if the required number of seconds have passed
		if((defBoostSeconds % defBoostRestore) == 0)
		{
			//stamina stone is fully charged
			PA_StartSpriteAnim(0, 4, 24, 24, 10);
			//reset flag
			defRecharge = false;
		}
	}	
}




//SPECIAL STONE
//---------------------------------------------
//---------------------------------------------
void useSpecialStone()
{
	PA_StopSpriteAnim(0, avSprNo); //stop any previous sprite animation
	
	//only execute if fully recharged
	if(specRecharge == false)
	{
		//fill special guage
		player.increaseSpecial(player.getMaxSpecial());
		
		//set animation and use for loop to wait until animation
		//is complete before moving on
		PA_StartSpriteAnimEx(0, 5, 32, 39, 10, 1, 1);
		for(counter = 0; counter < 30; counter++)
		{
		PA_WaitForVBL();
		}
		
		//start recharge animation
		PA_StartSpriteAnim(0, 5, 38, 39, 5);
		//make sure everything is reset before starting
		specBoostSeconds = 0;
		ResetTimer(specBoostClock);
		//set recharge to true
		specRecharge = true;
	}
	
}

//for recharging special stone
void chargeSpecialStone()
{
	//if a second has passed (1000 milliseconds)
	if(((specBoostSeconds + 1)*1000) <= Tick(specBoostClock))
	{	
		specBoostSeconds++;
		//if the required number of seconds have passed
		if((specBoostSeconds % specBoostRestore) == 0)
		{
			//stamina stone is fully charged
			PA_StartSpriteAnim(0, 5, 32, 32, 10);
			//reset flag
			specRecharge = false;
		}
	}	
}
	

#endif  //__BOOST_H__
